/*
 * Copyright (C) 2020, KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef MENUMODULE_H
#define MENUMODULE_H

#ifndef UKUI_THEME_GSETTING_PATH
#define UKUI_THEME_GSETTING_PATH "org.ukui.style"
#endif

#include <QApplication>
#include <QObject>
#include <QWidget>
#include <QMenu>
#include <QPushButton>
#include <QToolButton>
#include <QDebug>
#include <QString>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QRect>
#include <QScreen>
#include <QGSettings>
#include <QMetaEnum>

#include "daemonipcdbus.h"
#include "highlight-effect.h"
#include "kaboutdialog.h"
class menuModule : public QWidget
{
    Q_OBJECT
public:
    explicit menuModule(QWidget *);
    void changePageForTheme(const QString& str);

    bool hasAboutWindow();
    void closeAboutWindow();

    QToolButton *getMenuBtn();

    void changeFont(QFont curFont);
signals:
    void menuModuleClose();
    void menuModuleChanged(QString);

    void menuModuleSetThemeStyle(QString);

private:
    QToolButton *m_menuButton = nullptr;
    QMenu *m_menu = nullptr;

    QPushButton *m_titleIconBtn;
    QPushButton *m_bodyIcon = nullptr;

    QLabel* m_bodySupport;
    QLabel* m_titleText;
    QLabel* m_bodyAppName;
    QLabel* m_bodyAppVersion;

    kdk::KAboutDialog *m_aboutWindow = nullptr;

    QGSettings *m_pGsettingThemeData = nullptr;
    QGSettings *m_pGsettingThemeStatus = nullptr;

    QString m_currentStyle = "ukui-light";

    QString m_appVersion     = qApp->applicationVersion();
    QString m_appShowingName = tr("Services and Supports"); //格式services and supports ,用来在前端展示
    QString m_appName        = "Services-and-Supports";

    enum typeThemeStatus : int
    {
        themeAuto      = 0,
        themeBlackOnly = 1,
        themeLightOnly = 2
    } themeStatus;

    void init();
    QHBoxLayout* initTitleBar(); //关于窗口标题栏初始化
    QVBoxLayout* initBody();    // 关于窗口body初始化

    void initAction();
    void triggerMenu(QAction* act); //主菜单动作4
    void triggerThemeMenu(QAction* act); //主题动作
    void aboutAction();
    void initAbout(); //关于窗口初始化
    void helpAction();
};

#endif // MENUMODULE_H
